package io.imp.modules.tasks.unionqrc.dao;



import io.imp.modules.tasks.unionqrc.entity.ItcsTransJnl;
import io.imp.orm.dao.JpaDao;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.Date;
import java.util.List;

public interface ItcsTransJnlDao extends JpaDao<ItcsTransJnl,String> {



    /**
     * 根据订单号获取终端号和车站id
     * @param order_no
     * @return
     */
    @Query(value = "SELECT new ItcsTransJnl (terminalno , estationid) from ItcsTransJnl where orderno = :order_no")
    public ItcsTransJnl getTnoAndSid(@Param("order_no") String order_no);

    /**
     * 根据创建时间，支付时间获取指定时间段内的订单号，终端号，车站id
     * @param createtime
     * @param nowTime
     * @param lTime
     * @return
     */
    @Query(value = "select new ItcsTransJnl (orderno, terminalno, estationid) from ItcsTransJnl where createtime = :createtime and paytime <= :nowTime  AND paytime >= :lTime")
    public List<ItcsTransJnl> getByCreatetime(@Param("createtime") Date createtime, @Param("nowTime") Date nowTime, @Param("lTime") Date lTime);
}
